package GUI.gameWinOld;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;

import GUI.CardImages;

import carddeck.Suit;


@SuppressWarnings("serial")
public class AceSelectionButton extends JButton {
	private Suit cardSuit;
	private AceSelectionDialog dialog;
	private ImageIcon butIcon;
	private ImageIcon butIconHL;
	
	public AceSelectionButton(Suit color, AceSelectionDialog dlg) {
		cardSuit=color;
		dialog=dlg;
		
		setBorder(BorderFactory.createEmptyBorder());
		setContentAreaFilled(false);
		
		int val =1;
		if(cardSuit==Suit.HEARTS)
			;
		else if(cardSuit==Suit.DIAMONDS)
			val+=13;
		else if(cardSuit==Suit.CLUBS)
			val+=26;
		else if(cardSuit==Suit.SPADES)
			val+=39;
		
		butIcon = CardImages.getInstance().getII("/carddeck/conv/resizedH/"+val);
		butIconHL =CardImages.getInstance().getII("/carddeck/conv/resizedH/HL_B/"+val);
		deselect();
		addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				dialog.selected(AceSelectionButton.this);
			}
		});
	}
	
	public void select() {
		setIcon(butIconHL);
	}
	
	public void deselect() {
		setIcon(butIcon);
	}
	
	public Suit getSuit() {
		return cardSuit;
	}
}
